package crmdna.common;

import com.google.appengine.api.NamespaceManager;
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory;
import com.googlecode.objectify.ObjectifyService;

import crmdna.keyvaluestore.KeyValueEntity;
import crmdna.mail.MailStatsEntity;
import crmdna.mail.SentMailEntity;

public class OfyService {
  static {
    factory().register(SentMailEntity.class);
    factory().register(MailStatsEntity.class);
    factory().register(KeyValueEntity.class);
  }

  public static Objectify ofy(String client) {
    NamespaceManager.set(client);
    return ObjectifyService.ofy();
  }

  public static Objectify ofyCrmDna() {
    NamespaceManager.set("CRMDNA");
    return ObjectifyService.ofy();
  }

  public static ObjectifyFactory factory() {
    return ObjectifyService.factory();
  }
}
